package com.yunxin.download.config;


import com.yunxin.download.server.infra.support.mybatis.DownloadDaoInterceptor;
import jakarta.annotation.PostConstruct;
import org.apache.ibatis.session.SqlSessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;

import java.util.List;

/**
 * @author zero°
 * @since 2023-06-17
 */
@Configuration
public class MybatisConfig {


    @Autowired
    private List<SqlSessionFactory> sqlSessionFactoryList;

    @PostConstruct
    public void addDownloadDaoInterceptor() {
        DownloadDaoInterceptor interceptor = new DownloadDaoInterceptor();
        for (SqlSessionFactory sqlSessionFactory : sqlSessionFactoryList) {
            sqlSessionFactory.getConfiguration().addInterceptor(interceptor);

        }
    }


}
